<template>
  <van-popup
    :value="value"
    @input="$emit('input', $event)"
    @open="isReport = false"
  >
    <van-cell-group v-if="!isReport">
      <van-cell @click="dislikeArt" icon="closed-eye">不感兴趣</van-cell>
      <van-cell is-link @click="isReport = true">反馈垃圾内容</van-cell>
      <van-cell icon="info-o">拉黑作者</van-cell>
    </van-cell-group>
    <van-cell-group v-else>
      <van-cell icon="arrow-left" @click="isReport = false">返回</van-cell>
      <van-cell>侵权</van-cell>
      <van-cell>色情</van-cell>
      <van-cell>暴力</van-cell>
      <van-cell>低俗</van-cell>
      <van-cell>不适</van-cell>
      <van-cell>错误</van-cell>
      <van-cell>其他</van-cell>
    </van-cell-group>
  </van-popup>
</template>

<script>
import { dislikeArticle } from '../../../api/article'
export default {
  props: {
    value: {
      type: Boolean,
      default: false
    },
    // 当前点击文章的id
    articleId: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      // 是否显示上报垃圾内容
      isReport: false
    }
  },
  methods: {
    async dislikeArt () {
      try {
        await dislikeArticle(this.articleId)
        // 关掉操作弹层
        this.$emit('input', false)
        // 把不感兴趣文章从列表删除
        this.$emit('dislike')
        this.$toast.success('操作成功!')
      } catch (error) {
        console.log(error)
        this.$toast.fail('操作失败!')
      }
    }
  }
}
</script>

<style scoped lang='less'>
.van-popup {
  width: 80%;
  border-radius: 4px;
}
</style>
